package com.pozu.new_retail.utils;

import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.github.qcloudsms.SmsSingleSender;
import com.github.qcloudsms.SmsSingleSenderResult;

/**
 * @author ChaoDaiJin
 * @description 短信验证码
 * @date 2017年6月7日 下午3:09:32
 */
public class MsmUtil {
	
	private static final int SDK_App_ID = Integer.parseInt(PropertiesUtil.getString("SDK_App_ID"));
	private static final String App_Key = PropertiesUtil.getString("App_Key");
	private static final int msg_id = Integer.parseInt(PropertiesUtil.getString("msg_id"));
	private static Logger logger = Logger.getLogger(MsmUtil.class.getName());
	public static Object send(String nationCode,String phone){
		
		try {
			//初始化单发
			SmsSingleSender singleSender = new SmsSingleSender(SDK_App_ID, App_Key);

			String code = Tools.getRandomNumber(6);
			ArrayList<String> params = new ArrayList();
			params.add(code);
			SmsSingleSenderResult singleSenderResult = singleSender.sendWithParam(nationCode, phone, msg_id, params, "", "", "");
			CacheManager.setData(nationCode+phone+","+code);
			logger.log(Level.INFO,"验证码》"+code);
			return singleSenderResult;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
		
	}
}
